package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.SuifRegister;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Suif;
import com.ruoyi.system.service.ISuifService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 信息补充Controller
 * 
 * @author ruoyi
 * @date 2025-01-10
 */
@RestController
@RequestMapping("/system/suif")
public class SuifController extends BaseController
{
    @Autowired
    private ISuifService suifService;

    /**
     * 查询信息补充列表
     */
    @PreAuthorize("@ss.hasPermi('system:suif:list')")
    @GetMapping("/list")
    public TableDataInfo list(Suif suif)
    {
        startPage();
        List<Suif> list = suifService.selectSuifList(suif);
        return getDataTable(list);
    }

    /**
     * 导出信息补充列表
     */
    @PreAuthorize("@ss.hasPermi('system:suif:export')")
    @Log(title = "信息补充", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Suif suif)
    {
        List<Suif> list = suifService.selectSuifList(suif);
        ExcelUtil<Suif> util = new ExcelUtil<Suif>(Suif.class);
        util.exportExcel(response, list, "信息补充数据");
    }

    /**
     * 获取用户信息补充详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:suif:query')")
    @GetMapping(value = "/{userName}")
    public AjaxResult selectUserName(@PathVariable("userName") String userName)
    {
        Suif suif = suifService.selectUserName(userName);
        return AjaxResult.success(suif);
    }


    /**
     * 新增信息补充
     */
    @PreAuthorize("@ss.hasPermi('system:suif:add')")
    @Log(title = "信息补充", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SuifRegister suif)
    {
        return toAjax(suifService.insertSuif(suif));
    }

    /**
     * 修改信息补充
     */
    @PreAuthorize("@ss.hasPermi('system:suif:edit')")
    @Log(title = "信息补充", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Suif suif)
    {
        return toAjax(suifService.updateSuif(suif));
    }

    /**
     * 删除信息补充
     */
    @PreAuthorize("@ss.hasPermi('system:suif:remove')")
    @Log(title = "信息补充", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(suifService.deleteSuifByIds(ids));
    }
}
